package com.itheima.servlet.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// req.html
// 演示POST/GET请求参数中文乱码问题解决方案
@WebServlet("/req04")
public class RequestDemo04 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1.解决乱码：POST，getReader()
        // 2.获取username

        // 3.GET,获取参数的方式：getQueryString     乱码原因：tomcat进行URL解码，默认的字符集ISO-8859-1
        // 3.1 先对乱码数据进行编码转为字节数组,再使用UTF-8解码为字符串

    }
}
